//
//  ZMZSFenLeiViewController.m
//  ZhangMiZhuShou
//
//  Created by ryou on 2021/7/26.
//

#import "ZMZSFenLeiViewController.h"
#define kpmImageArray @[@"zmxzs_icon_game.png",@"zmxzs_icon_mail.png",@"zmxzs_icon_kahao.png",@"zmxzs_icon_jilu.png",@"zmxzs_icon_shejiao.png",@"zmxzs_icon_gouwu.png",@"zmxzs_icon_zhanghao.png",]

#import "ZMZSXiangQingLieBiaoViewController.h"
@interface ZMZSFenLeiViewController ()
@end

@implementation ZMZSFenLeiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"分类";
    
    CGFloat ZMZSspace  = 40 ;
    
    CGFloat ZMZSitemW =(kZMXZSWidth - ZMZSspace  *2 - 10 )/2;
    UIWindow * window = [[UIApplication sharedApplication].delegate window];
    CGFloat bottom = 0.0;
    if (@available(iOS 11.0, *)) {
        bottom = window.safeAreaInsets.top;
    } else {
        // Fallback on earlier versions
    }
        CGFloat yyy=self.navigationController.navigationBar.frame.origin.y +  self.navigationController.navigationBar.frame.size.height + bottom;
//    CGFloat yyy=0;
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:self.view.bounds];
    scrollView.contentSize = CGSizeMake(kZMXZSWidth, yyy + ZMZSspace +(ZMZSitemW  + 10) * (5 / 2) + ZMZSitemW / 2 + ZMZSitemW / 2 - 10);
    [self.view addSubview:scrollView];
    for (int i=0; i<7; i++) {
        
        UIImageView *ZMZSZMZSAcountMbgimage=[[UIImageView alloc]initWithFrame:CGRectMake(ZMZSspace +(ZMZSitemW  + 10) * (i%2),yyy + ZMZSspace +(ZMZSitemW  + 10) * (i / 2), ZMZSitemW, ZMZSitemW)];
        ZMZSZMZSAcountMbgimage.image=[UIImage imageNamed:@"zmxzs_icon_cellbg.png"];
        ZMZSZMZSAcountMbgimage.contentMode=UIViewContentModeScaleToFill;
        ZMZSZMZSAcountMbgimage.layer.cornerRadius=10;
        
        ZMZSZMZSAcountMbgimage.clipsToBounds=YES;
        [scrollView addSubview:ZMZSZMZSAcountMbgimage];
        
        if (i == 2) {
            ZMZSZMZSAcountMbgimage.frame=CGRectMake(ZMZSZMZSAcountMbgimage.frame.origin.x, ZMZSZMZSAcountMbgimage.frame.origin.y, ZMZSZMZSAcountMbgimage.frame.size.width , ZMZSZMZSAcountMbgimage.frame.size.height/2-10);
        }
        if(i == 4){
            ZMZSZMZSAcountMbgimage.frame = CGRectMake(ZMZSspace ,yyy + ZMZSspace +(ZMZSitemW  + 10)  + ZMZSitemW / 2 + 10, ZMZSitemW, ZMZSitemW / 2 - 10 );
        }
        if (i==5) {
            ZMZSZMZSAcountMbgimage.frame = CGRectMake(ZMZSspace ,yyy + ZMZSspace +(ZMZSitemW  + 10) * (i / 2), kZMXZSWidth - ZMZSspace * 2, ZMZSitemW / 2 - 10);
        }
        if (i==6) {
            ZMZSZMZSAcountMbgimage.frame = CGRectMake(ZMZSspace ,yyy + ZMZSspace +(ZMZSitemW  + 10) * (5 / 2) + ZMZSitemW / 2 , kZMXZSWidth - ZMZSspace * 2, ZMZSitemW / 2 - 10);
        }
        
        UIImageView *ZMZSAcountMiconImage=[[UIImageView alloc]initWithFrame:CGRectMake(50, 50, ZMZSZMZSAcountMbgimage.bounds.size.width - 100, ZMZSZMZSAcountMbgimage.bounds.size.height - 100)];
        ZMZSAcountMiconImage.image=[UIImage imageNamed:kpmImageArray[i]];
        ZMZSAcountMiconImage.contentMode=UIViewContentModeScaleAspectFit;
        [ZMZSZMZSAcountMbgimage addSubview:ZMZSAcountMiconImage];
        
        ZMZSZMZSAcountMbgimage.userInteractionEnabled=YES;
        UITapGestureRecognizer *zmxzspmtap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(bgClick)];
        [ZMZSZMZSAcountMbgimage addGestureRecognizer:zmxzspmtap];
    }
    // Do any additional setup after loading the view.
}
-(void)bgClick{
    ZMZSXiangQingLieBiaoViewController *zmxzspmadd=[[ZMZSXiangQingLieBiaoViewController alloc]init];
    [self.navigationController pushViewController:zmxzspmadd animated:YES];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */


@end

